var mysql = require('mysql');
var userPool = false;

var sql = "SELECT a.* FROM shop_order_item a left join shop_order b on a.MAIN_ORDER_NO=b.MAIN_ORDER_NO and b.IS_MAIN=1  "
		+ "left join shop_order_customer_check c on a.CUSTOMER_STATEMENT_ID=c.ID "
		+ "left join shop_order_supplier_check d on a.SUPPLIER_STATEMENT_ID=d.ID  where 1=1  and a.STATE=1 and b.STATE=1 order by c.CHECK_TIME desc ";

var connection = mysql.createConnection({
	host : 'localhost',
	user : 'root',
	password : 'root',
	database : 'industry-platform',
	typeCast : true
});

connection.connect();

connection.query(sql, function(err, rows, fields) {
	if (err)
		throw err;
	console.log('The solution is: ', rows);
});

connection.end();
